﻿@model FormulaRunning.Models.Formula

@{
    ViewBag.Title = "Edit Formula";
}

<h2>Edit Formula</h2>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Edit Formula</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.FormulaString)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FormulaString)
            @Html.ValidationMessageFor(model => model.FormulaString)
        </div>

        @for (var i = 0; i < ((FormulaRunning.Models.Tag[])ViewBag.Tags).Length; i++)
        {
            var checkedValue = false;
            if (Model != null && Model.Tags != null && Model.Tags.Contains(((FormulaRunning.Models.Tag[])ViewBag.Tags)[i]))
            {
                checkedValue = true;
            }
                    
            @Html.CheckBox("TagName", @checkedValue, new { value = ((FormulaRunning.Models.Tag[])ViewBag.Tags)[i].TagID })
            @(((FormulaRunning.Models.Tag[])ViewBag.Tags)[i].TagName)
             
        }

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
